package com.wc.alorithm_blue_bridge._排序.Q5639;


import java.util.Arrays;
import java.util.Scanner;

/**
 * @Author congge
 * @Date 2023/12/19 12:48
 * 鸟儿的和谐程度
 * https://www.lanqiao.cn/problems/5639/learning/?page=1&first_category_id=1
 * @description
 */
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        Bird[] birds = new Bird[n];
        for (int i = 0; i < n; i++) {
            birds[i] = new Bird();
            birds[i].a = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            birds[i].b = sc.nextInt();
        }
        Arrays.sort(birds);
        if (Math.abs(birds[0].b) > Math.abs(birds[n - 1].b)) {
            if (birds[0].b > 0) {
                birds[0].a += k;
            } else {
                birds[0].a -= k;
            }
        } else {
            birds[n - 1].a -= k;
        }

        long ans = 0;
        for (int i = 0; i < n; i++) {
            ans += ((long) birds[i].a * birds[i].b);
        }
        System.out.println(ans);
    }

    static class Bird implements Comparable<Bird> {
        int a;
        int b;

        @Override
        public int compareTo(Bird o) {
            return o.b - this.b;
        }
    }
}
